from django.contrib.auth.models import User, Group
from tutorial.quickstart.models import MovieMaoyan, ArticleList
from tutorial.quickstart.models import MovieCelebrityList
from tutorial.quickstart.models import MovieCommentList
from rest_framework import serializers


class UserSerializer(serializers.ModelSerializer):
    # ModelSerializer
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')


class GroupSerializer(serializers.ModelSerializer):
    class Meta:
        model = Group
        fields = ('url', 'name')


class MovieSerializer(serializers.ModelSerializer):
    class Meta:
        model = MovieMaoyan
        fields = ('movie_id', 'cover_url', 'movie_name', 'actor', 'release_time', 'movie_introduce')


# 电影演职员
class MovieCelebrityListSerializer(serializers.ModelSerializer):
    class Meta:
        model = MovieCelebrityList
        fields = ('movie_id', 'celebrity_type', 'cover_url', 'celebrity_name', 'celebrity_role')


# 电影评论
class MovieCommentListSerializer(serializers.ModelSerializer):
    class Meta:
        model = MovieCommentList
        fields = ('movie_id', 'nick_name', 'cover_url', 'comment_date', 'comment_content')


# 精选文章
class ArticleListSerializer(serializers.ModelSerializer):
    class Meta:
        model = ArticleList
        fields = ('article_id', 'title', 'extra')
